package com.cw.lang.common.utils.context;

import java.util.Map;

/**
 * @author chenw
 * @version $$Id: ThreadContextStoreUtil.java, v 0.1 2018/9/19 下午2:15 chenw Exp $$
 */
public final class ThreadContextStoreUtil extends AbstractThreadContext {

    private static ThreadLocal<Map<String, Object>> threadContext = new ThreadLocal<>();

    private static volatile ThreadContextStoreUtil app = null;

    private ThreadContextStoreUtil() {}

    /**
     * 获取实例
     *
     * @return 实例
     */
    public static synchronized ThreadContextStoreUtil getInstance() {
        if (app == null) {
            synchronized (ThreadContextStoreUtil.class) {
                if (app == null) {
                    app = new ThreadContextStoreUtil();
                }
            }
        }
        return app;
    }

    @Override
    protected ThreadLocal<Map<String, Object>> getThreadContext() {
        return threadContext;
    }

}
